package com.haixiaoke.saas.manage.house.controller;

import java.util.List;

import com.haixiaoke.saas.common.annotation.Log;
import com.haixiaoke.saas.common.core.domain.AjaxResult;
import com.haixiaoke.saas.common.enums.BusinessType;
import com.haixiaoke.saas.house.domain.HouseFacilities;
import com.haixiaoke.saas.house.service.IHouseFacilitiesService;
import com.haixiaoke.saas.system.BaseController;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 服务设施Controller
 * 
 * @author panda
 * @date 2025-06-25
 */
@RestController
@RequestMapping("/manage/house/facilities")
public class ManageHouseFacilitiesController extends BaseController {
    @Autowired
    private IHouseFacilitiesService houseFacilitiesService;

    /**
     * 查询服务设施列表
     */
    @GetMapping("/list")
    public AjaxResult list(HouseFacilities houseFacilities) {
        List<HouseFacilities> list = houseFacilitiesService.selectHouseFacilitiesList(houseFacilities);
        return success(list);
    }

    /**
     * 获取服务设施详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:facilities:query')")
    @GetMapping(value = "/{facilitiesId}")
    public AjaxResult getInfo(@PathVariable("facilitiesId") Long facilitiesId) {
        return success(houseFacilitiesService.selectHouseFacilitiesByFacilitiesId(facilitiesId));
    }

    /**
     * 新增服务设施
     */
    @PreAuthorize("@ss.hasPermi('business:facilities:add')")
    @Log(title = "服务设施", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HouseFacilities houseFacilities) {
        return toAjax(houseFacilitiesService.insertHouseFacilities(houseFacilities));
    }

    /**
     * 修改服务设施
     */
    @PreAuthorize("@ss.hasPermi('business:facilities:edit')")
    @Log(title = "服务设施", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HouseFacilities houseFacilities) {
        return toAjax(houseFacilitiesService.updateHouseFacilities(houseFacilities));
    }

    /**
     * 删除服务设施
     */
    @PreAuthorize("@ss.hasPermi('business:facilities:remove')")
    @Log(title = "服务设施", businessType = BusinessType.DELETE)
	@DeleteMapping("/{facilitiesIds}")
    public AjaxResult remove(@PathVariable Long[] facilitiesIds) {
        return toAjax(houseFacilitiesService.deleteHouseFacilitiesByFacilitiesIds(facilitiesIds));
    }
}
